$OpenBSD: patch-src_openvpn_route_c,v 1.10 2017/06/11 12:15:50 jca Exp $

- add support for on-link routes

- add support for non-0 routing tables
  https://github.com/OpenVPN/openvpn/commit/3dd30bfe5fdf9f34afe7f847b4e30156982d9ff0

--- src/openvpn/route.c.orig	Thu Mar 23 02:34:21 2017
+++ src/openvpn/route.c	Wed Apr 12 18:06:40 2017
@@ -1778,12 +1778,17 @@ add_route(struct route_ipv4 *r,
     }
 #endif
 
-    argv_printf_cat(&argv, "-net %s %s -netmask %s",
+    argv_printf_cat (&argv, "-net %s -netmask %s",
                     network,
-                    gateway,
                     netmask);
 
-    /* FIXME -- add on-link support for OpenBSD/NetBSD */
+    /* FIXME -- add on-link support for NetBSD */
+#ifdef TARGET_OPENBSD
+    if (is_on_link (is_local_route, flags, rgi))
+        argv_printf_cat (&argv, "-link -iface %s", rgi->iface);
+    else
+#endif
+        argv_printf_cat (&argv, "%s", gateway);
 
     argv_msg(D_ROUTE, &argv);
     status = openvpn_execve_check(&argv, es, 0, "ERROR: OpenBSD/NetBSD route add command failed");
@@ -3597,6 +3602,9 @@ get_default_gateway(struct route_gateway_info *rgi)
     rtm.rtm_flags = RTF_UP | RTF_GATEWAY;
     rtm.rtm_version = RTM_VERSION;
     rtm.rtm_seq = ++seq;
+#ifdef TARGET_OPENBSD
+    rtm.rtm_tableid = getrtable();
+#endif
     rtm.rtm_addrs = rtm_addrs;
 
     so_dst.sa_family = AF_INET;
@@ -3812,6 +3820,9 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_inf
     rtm.rtm_flags = RTF_UP;
     rtm.rtm_version = RTM_VERSION;
     rtm.rtm_seq = ++seq;
+#ifdef TARGET_OPENBSD
+    rtm.rtm_tableid = getrtable();
+#endif
 
     so_dst.sin6_family = AF_INET6;
     so_mask.sin6_family = AF_INET6;
